<template>
  <div class="box">
    <div class="box">
      <button @click="showToast('登录')">登录</button>
    </div>
    <div class="box">
      <button @click="showToast('注册')">注册</button>
    </div>

    <div class="box">
      <button @click="showToast('加入购物车')">加入购物车</button>
    </div>

    <div class="mask" v-show="isShow">
      <div class="con">{{msg}}成功</div>
    </div>

  </div>
</template>

<script>
export default {
    data(){
        return {
            isShow:false,
            msg:''
        }
    },
    methods:{
        showToast(msg){
            this.isShow = true
            this.msg = msg
            
            setTimeout(()=>{
                this.isShow = false
            },2000)
        }
    }
};
</script>

<style scoped>
.mask {
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.3);
  position: absolute;
  top: 0;
  left: 0;
}
.mask .con {
  width: 200px;
  height: 100px;
  background-color: white;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>